﻿namespace Sheep_Breeding.ErrorCode
{
    /// <summary>
    /// 响应标准返回值
    /// </summary>
    public class ApiResult
    {
        /// <summary>
        /// 响应类型
        /// </summary>
        public ApiREunm code {  get; set; }=ApiREunm.Fail;
        /// <summary>
        /// 响应信息
        /// </summary>
        public string msg { get; set; } = "操作失败";

        /// <summary>
        /// 响应数据
        /// </summary>
        public object data {  get; set; }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="msg"></param>
        public void success(string msg)
        {
            this.msg = msg;
            this.code = ApiREunm.Ok;
        }
 
    }

    public class ApiResult<T>
    {
        /// <summary>
        /// 响应类型
        /// </summary>
        public ApiREunm code { get; set; } = ApiREunm.Fail;
        /// <summary>
        /// 响应信息
        /// </summary>
        public string msg { get; set; } = "操作失败";

        /// <summary>
        /// 响应数据
        /// </summary>
        public T data { get; set; }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="msg">消息</param>
        /// <param name="data">数据</param>
        public void success(string msg, T data)
        {
            this.msg = msg;
            this.code = ApiREunm.Ok;
            this.data = data;
        }

    }
}
